/*
https://leetcode-cn.com/problems/minimum-number-of-arrows-to-burst-balloons/solution/yong-zui-shao-shu-liang-de-jian-yin-bao-qi-qiu-1-2/
 */
import java.util.Arrays;
import java.util.Comparator;

public class Solution452 {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points, Comparator.comparingInt(a -> a[1]));
        int ans=1;
        int cur=points[0][1];
        for (int i=0;i<points.length;i++){
            if (points[i][0]>cur){
                ans++;
                cur=points[i][1];
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution452().findMinArrowShots(new int[][]{{10,16},{2,8},{1,6},{7,12}}));
    }
}
